home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 52 / Amiga Format AFCD52 (Issue 136, May 2000).iso / -serious- / programming / basic / mildred / lha / pixelexplosion4.lha / 2DPixelExplosion4.ascii next >
Text File  |  1999-03-30  |  4KB  |  120 lines

  1.  
  2. ;Pixel Explosion Mildred Library Example.
  3. ;
  4. ;Programmed by : Mikkel Loekke, aka. FlameDuck.
  5. ;
  6. ;Please read the README file.
  7.  
  8. ;                  __ _
  9. ;Modified by Sami Naatanen (25.01.1999)
  10. ; Just made it faster and more "realistic"
  11. ; Can now do easily 4000 pixels and 060 with 10000 stars is still
  12. ; super smooth! In fact 15000 stars runs quite smooth
  13. ; (some jerking at the beginning).
  14.  
  15. ;Modified by Paul West (10.2.1999)
  16. ; Split point newtypes into two distinct groups
  17. ; Implemented particle animation routines, speed is *at least* 200%!!
  18.  
  19. WBStartup
  20. NoCli
  21.  
  22. degrad.q = Pi/180
  23.  
  24. NEWTYPE .point
  25.   x.q
  26.   y.q
  27. End NEWTYPE
  28. NEWTYPE .point2
  29.   anglx.q
  30.   angly.q
  31. End NEWTYPE
  32.  
  33. #numpnts=5000                       ; Change this for more or less points.
  34.  
  35. Dim pnt.point (#numpnts)
  36. Dim pnt2.point2 (#numpnts)
  37.  
  38. DEFTYPE.l
  39.  
  40. MCPU Processor                      ; Tell Mildred which CPU it should use.
  41. Mc2pCPUmode Processor               ; Tell Mildred which CPU it should use for c2p.
  42.  
  43. MReserveBitmaps 1                   ; Tell Mildred that we're going to use 1 chunky bitmap.
  44. MReservec2pWindows 1                ; Tell it we only need one c2p display.
  45. MReserveShapes 1                    ; Tell Mildred that we need a shape aswell.
  46.  
  47. InitPalette 0,256                   ; Setup a grayscale palette.
  48. For t.l=0To 255
  49.   AGAPalRGB 0,t,t,t,t
  50. Next
  51.  
  52. .initgraphics
  53. MBitmap 0,320,256                   ; This will contain our chunky buffer.
  54.  
  55. Mc2pWindow 0,320,256                ; Setup structures for c2p conversions.
  56.  
  57. *pbb.l=AllocMem(320*256,$10002)     ; Get some free CHIP memory
  58. If *pbb.l                           ; and if we succeed
  59.   CludgeBitMap 0,320,256,8,*pbb     ; make it a planar bitmap.
  60. Else End
  61. EndIf
  62.  
  63. Dim scrtaglst.TagItem(7)            ; All this stuff sets up our
  64. scrtaglst(0)\ti_Tag = #SA_Left      ; Taglist for the screen we
  65. scrtaglst(0)\ti_Data = 0            ; want.
  66. scrtaglst(1)\ti_Tag = #SA_Depth
  67. scrtaglst(1)\ti_Data = 8
  68. scrtaglst(2)\ti_Tag = #SA_Width
  69. scrtaglst(2)\ti_Data = 320
  70. scrtaglst(3)\ti_Tag = #SA_Height
  71. scrtaglst(3)\ti_Data = 256
  72. scrtaglst(4)\ti_Tag = #SA_BitMap
  73. scrtaglst(4)\ti_Data = Addr BitMap (0)
  74. scrtaglst(5)\ti_Tag = #SA_ShowTitle
  75. scrtaglst(5)\ti_Data = 0
  76. scrtaglst(6)\ti_Tag = #SA_Draggable
  77. scrtaglst(6)\ti_Data = 0
  78. scrtaglst(7)\ti_Tag = #TAG_END      ; The most important tag of them all.
  79.  
  80. ScreenTags 0,"MildredDEMO",&scrtaglst(0) ; Open our intuition screen.
  81.  
  82. ShowPalette 0                       ; Attach our palette to the screen.
  83.  
  84.  
  85. Dim cin.q(359),kos.q(359)
  86.  
  87. For t.l=0 To 359
  88.   cin(t)=Sin(degrad*t)
  89.   kos(t)=Cos(degrad*t)
  90. Next t
  91. MParticleFormat -1
  92. MParticleMode MAddMode
  93. .goagain                            ; A Label that tells us where to go
  94.                                     ; to reset all our variables
  95. centerx.q=80+Rnd(160)
  96. centery.q=64+Rnd(128)
  97. For t.l=0To #numpnts
  98.   pnt(t)\x=centerx
  99.   pnt(t)\y=centery
  100.   r.w=Rnd(359)
  101.   v.q=Rnd(Rnd(4.4)+3)+Rnd(1.6)
  102.   pnt2(t)\anglx=cin(r)*v
  103.   pnt2(t)\angly=kos(r)*v
  104. Next
  105.  
  106. phase.w=0
  107. pntskip.w=0
  108. Repeat                              ; Repeat our mainloop ....
  109.   Mc2p *pbb                         ; Convert our chunky buffer to
  110.   MCls
  111.   MAddToParticles &pnt(0)\x,#numpnts,&pnt2(0)\anglx
  112.   MBitmapClip 0,On
  113.   MPlotParticles &pnt(0)\x,#numpnts,20;255-phase
  114.   MBitmapClip 0,Off
  115.   phase+2:If phase=256 Then pntskip=#numpnts
  116. Until RawStatus($45) OR pntskip=#numpnts  ; .... Until we press Escape, or the fade is complete.
  117. If pntskip=#numpnts Then Goto goagain     ; If the fade completed, reset variables, and go again.
  118. End                                 ; End our nice program.
  119.  
  120.